           package com.java.diagnostics.visualizer.displayer.plot;
           
           import com.java.diagnostics.visualizer.data.TupleData;
           import com.java.diagnostics.visualizer.impl.factory.LogFactory;
           import com.java.diagnostics.visualizer.properties.OutputProperties;
           import java.util.logging.Level;
           import java.util.logging.Logger;
           
           public class XPositionConverter extends PositionConverter
           {
             protected static final double DELTA_OFFSET = 1.0E-007D;
             private static final Logger TRACE = LogFactory.getTrace(XPositionConverter.class);
             protected int plotLeft;
             protected int plotWidth;
           
             public int convertToPosition(double num)
             {
               double offset = num - this.lowerLimit;
               double unrounded;
               //double unrounded;
               if (this.delta > 1.0E-007D)
                 unrounded = offset * (this.plotWidth / this.delta) + this.plotLeft;
               else {
                 unrounded = this.plotLeft + this.plotWidth / 2;
               }
               return (int)Math.round(unrounded);
             }
           
             public double convertToValue(int position) {
               double offset = (position - this.plotLeft) / (this.plotWidth / this.delta);
               return offset + this.lowerLimit;
             }
           
             protected void calculateDeltas() {
               this.delta = (this.max - this.min);
               this.lowerLimit = this.min;
           
               this.delta += 1.0E-007D;
             }
           
             public void updateLimits(int plotLeft, int plotRight)
             {
               this.plotLeft = plotLeft;
               this.plotWidth = (plotRight - plotLeft);
             }
           
             public void updateLabelsAndAxes(OutputProperties properties, TupleData data)
             {
               if (data.isEmpty()) {
                 return;
               }
           
               double minXdata = data.getMinX(properties.getXUnits(data));
               if (minXdata < this.min)
               {
                 if (TRACE.isLoggable(Level.FINER)) {
                   TRACE.finer("Getting min x from data,");
                 }
                 this.min = minXdata;
               }
           
               double maxXdata = data.getMaxX(properties.getXUnits(data));
               if (maxXdata > this.max) {
                 this.max = maxXdata;
               }
               calculateDeltas();
             }
           }

